package com.cdream.basic.util;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.db.ds.simple.SimpleDataSource;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import lombok.Data;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toMap;
@Slf4j
public class EasyExcelUtilExample2 {

    public static void main(String[] args) throws SQLException {
        // EasyExcel.read("~/Desktop/凯德权限清单.xlsx").doReadAll();
        String string = FileUtil.readString("/Users/apple/Desktop/电站i18n.json", "UTF-8");
        log.info(string);
        JSONObject jsonObject = JSONUtil.parseObj(string);
        List<List<Object>> read = ExcelUtil.getReader("~/Desktop/epgs菜单.xls").read();
        for (List<Object> objects : read) {
            if (objects.size()<2){
                continue;
            }
            objects.add(jsonObject.getStr(String.valueOf(objects.get(1))));
        }
        ExcelUtil.getWriter("~/Desktop/epgs菜单new.xls").write(read).flush();
        log.info("..");
        // EasyExcel.write("/Users/apple/Desktop/类目.xlsx").sheet("类目列表").doWrite(realRes);

    }
}
